<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * db 统一设置各种操作如生成id,分页等
 *
 */
class Dblib {
	var $CI;
	function __construct()
	{
		$this->CI = & get_instance();
	}
	
	//生成主键id
	function create_id($id_field='id')
	{
		$this->CI->db->set($id_field, '(SELECT UUID())', FALSE);
	}
	
	//分页
	function query_limit($limit=10, $offset=0)
	{
		$this->CI->db->limit($limit, $offset);
	}
	
	//controller直接调用，获取传递上来的limit和offset，设置分页
	function set_query_limit()
	{
		$limit = $this->CI->input->post('page_size');
		$offset = $this->CI->input->post('page_from');
		$this->query_limit($limit, $offset);
	}
}